from selenium import webdriver
from selenium.webdriver.common.by import By

driver = webdriver.Chrome()
driver.get('https://www.baidu.com')

# xpath模糊匹配
hao = driver.find_element(By.XPATH, '//a[contains(text(), "hao")]')
print(hao.get_attribute('outerHTML'))

result = driver.find_element(By.XPATH, '//*[contains(@id, "result")]')
print(result.get_attribute('outerHTML'))

driver.quit()
